﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.IO;

namespace XmlDSigEx
{
    static class Extensions
    {
        internal static List<T> ConvertToListOf<T>(this XmlNodeList nodeList)
        {
            return new List<T>(nodeList.OfType<T>());
        }

        internal static bool IsEqualTo(this byte[] a, byte[] b)
        {
            for (int i = 0; i < a.Length; i++)
            {
                if (a[i] != b[i])
                    return false;
            }
            return true;
        }

        internal static string DumpSeekableStream(this Stream stream)
        {
            long position = stream.Position;
            stream.Position = 0;
            StreamReader reader = new StreamReader(stream);
            string dump = reader.ReadToEnd();
            stream.Position = position;
            return dump;
        }
    }
}
